package com.example.exam;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;


public class NetWork {
    public String getNetWork(Context context) {
        ConnectivityManager systemService = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = systemService.getActiveNetworkInfo();
        if(activeNetworkInfo==null){
            return "--";
        }
        int type = activeNetworkInfo.getType();
        if(type==ConnectivityManager.TYPE_MOBILE){
            return "4G/3G";
        }
        if(type==ConnectivityManager.TYPE_WIFI){
            return "wifi";
        }
        return null;
    }
}
